import {request} from "@@/plugin-request/request";


/** 登录接口 POST /api/login/account */
export async function adminLogin(body: BZAPI.LoginParams, options?: { [key: string]: any }) {
    return request<BZAPI.LoginResult>('/api/admin/login', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        data: body,
        ...(options || {}),
    });
}

/** 登录接口 POST /api/login/account */
export async function getMenus() {
    return request('/api/menu/user', {
        method: 'POST'
    });
}

/**
 * 获取催收人员的案件列表
 */
export async function getAgentCaseList(params: BZAPI.AgentCaseListParams) {
    return request('/api/collection/v2/distributeOrderGet/list?currentPage=' + params.page + '&pageSize=' + params.pageSize, {
        method: 'POST',
        data: params
    });
}

export async function getPayLink(tradeNo: string) {
    return request('/api/collection/v2/payLink/' + tradeNo, {
        method: 'POST'
    });

}

export async function getExtensionLink(tradeNo: string) {
    return request('/api/collection/v2/extentionLink/' + tradeNo, {
        method: 'POST'
    });

}

export async function getUsrProfileInfo(params: any) {
    return request('/api/collection/v2/user/base/info', {
        method: 'POST',
        data: params
    });

}

export async function getRelatives(params: any) {
    return request('/api/collection/v2/emergency/contacts/list', {
        method: 'POST',
        data: params
    });

}

export async function getRecordOptions(params: any) {
    return request('/api/collection/v2/case/query', {
        method: 'POST',
        data: params
    });

}


export async function addCollectionLog(params: BZAPI.AddCommentLog) {
    return request('/api/collection/v2/comment/add', {
        method: 'POST',
        data: params
    });

}

export async function addPhoneLog(params: BZAPI.AddCallLog) {
    return request('/api/collection/v2/phone/record/add', {
        method: 'POST',
        data: params
    });

}


export async function getAddressBook(params: any) {
    return request('/api/collection/v2/addressbook/contacts/list', {
        method: 'POST',
        data: params
    });

}

export async function getImages(params: any) {
    return request('/api/collection/v2/images/'+params.collectionNo, {
        method: 'POST',
        data: params
    });

}

export async function getTodayStats(params: any) {
    return request('/api/bizStats/general/query', {
        method: 'POST',
        data: {queryKey:"todayAdminPerformace"}
    });

}


export type LoginParamsType = {
    username: string;
    password: string;
};

export async function login(params: any) {
    console.log(params);
    return request('/api/admin/login', {
        method: 'POST',
        data: params,
    });
}

export async function getProductList(params: any) {
    return request('/api/product/list', {
        method: 'POST',
        data: params,
    });
}

export async function getOpdList(params: any) {
    return request('/api/open/data/list', {
        method: 'POST',
        data: params,
    });
}

export async function updateOptData(params: any) {
    return request('/api/open/data/update', {
        method: 'POST',
        data: params,
    });
}

export async function updateProduct(params: any) {
    return request('/api/wa/update', {
        method: 'POST',
        data: params,
    });
}

export async function saveOpenData(params: any) {

    return request('/api/open/data/save', {
        method: 'POST',
        data: params,
    });
}

export async function addProduct(params: any) {

    return request('/api/product/add', {
        method: 'POST',
        data: params,
    });
}


export async function getChannelList(params: any) {
    return request('/api/sms/channel/list', {
        method: 'POST',
        data: params,
    });
}


export async function getTemplateList(params: any) {
    return request('/api/sms/template/list', {
        method: 'POST',
        data: params,
    });
}

export async function getRobotList(params: any) {
    return request('/api/wa/list', {
        method: 'POST',
        data: params,
    });
}

export async function getAgentsList(params: any) {
    return request('/api/admin/agents/list', {
        method: 'POST',
        data:params
    });
}

export async function getAccountList(params: any) {
    return request('/api/bizStats/general/query2' +
        '', {
        method: 'POST',
        data: { queryKey: 'accountList' },
    });
}

export async function getGroupList(params: any) {
    return request('/api/bizStats/general/query2' +
        '', {
        method: 'POST',
        data: { queryKey: 'groupList' },
    });
}


export async function updateAgent(params: any) {
    return request('/api/admin/agent/update/' + params.agentCode+"?groupCode="+params.groupName+"&collectionAccountCode="+params.collectionAccountName, {
        method: 'POST',
        data: {},
    });
}






